<%@page import="java.util.List"%>
<%@page import="entities.Category"%>
<%@page import="helpers.PaginatorHelper"%>
<%@page import="helpers.UrlHelper"%>
<%@page import="java.util.ArrayList"%>
<%
List<Category> categories = (List<Category>) request.getAttribute("categories");
int pages = (Integer) request.getAttribute("page");
boolean nextPage = (Boolean) request.getAttribute("nextPage");
boolean prevPage = (Boolean) request.getAttribute("prevPage");
PaginatorHelper paginator = (PaginatorHelper) request.getAttribute("paginator");
%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<jsp:include page="/admin/layouts/header.jsp" />

<script type="text/javascript" src="/admin/js/custom/category_list.js"></script>

				<jsp:include page="/admin/elements/heading_panel.jsp" />

                <!-- Build page from here: -->
                <div class="row-fluid">
					<div class="span12">
						<jsp:include page="/admin/elements/message_box.jsp" />
					
                    	<div class="box">
                        	<div class="title">
                                <h4>
                                    <span class="icon16 icomoon-icon-list-view"></span>
                                    <span>Category List</span>
                                </h4>
                                <a href="#" class="minimize">Minimize</a>
                            </div>
                            <div class="content noPad">
                                <table class="responsive table table-bordered" id="checkAll">
                                    <thead>
                                      <tr>
                                        <th>Id</th>
                                        <th>Title</th>
                                        <th>Parent</th>
                                        <th>Status</th>
                                        <th>Actions</th>
                                      </tr>
                                    </thead>
                                    <tbody>
                                      <% for (int i = 0; i < categories.size(); i++) { %>
                                      <tr>
                                        <td><%=categories.get(i).getId() %></td>
                                        <td><%=categories.get(i).getName() %></td>
                                        <td><%=categories.get(i).getParentId() %></td>
                                        <td>
                                        	<%
											switch (categories.get(i).getStatus()) {
												case 0: 
													%>Inactive<%
													break;
												case 1:
													%>Pending<%
													break;
												case 2:
													%>Active<%
													break;
												default:
													break;
											}
											%>
                                        </td>
                                        <td>
                                            <div class="controls center">
                                                <a href="/admin/category/edit/<%=categories.get(i).getId()%>" title="Edit Category" class="tip"><span class="icon12 icomoon-icon-pencil"></span></a>
                                                <a href="/admin/category/delete/<%=categories.get(i).getId()%>" title="Remove Category" class="tip delete"><span class="icon12 icomoon-icon-remove"></span></a>
                                            </div>
                                        </td>
                                      </tr>
                                      <% } %>
                                    </tbody>
                                </table>
                            </div>
						</div><!-- End .box -->
						
						<ul class="pager">
							<% if (prevPage) { %>
							<li>
                                <a href="<%=paginator.getPrev()%>">Previous</a>
                            </li>
							<% }%>
                            <% if (nextPage) { %>
                             <li>
                                <a href="<%=paginator.getNext()%>">Next</a>
                            </li>
                            <%}%>
                        </ul>
						
					</div><!-- End .span6 -->

				</div><!-- End .row-fluid -->
                
<jsp:include page="/admin/layouts/footer.jsp" />